import { dingTalkApi, dTalkApiUtil } from 'dingtalk-app';
import dTalkApiUtils from './../core/lib/util/dTalkApiUtils';
import * as rq from 'request-promise'
import env from './../config/env';
import * as moment from 'moment';
import bpm from "./../core/lib/db/BPM";
import { userModel } from "./../model/userModel";

export class TestService {
    num :number = 0
    async test (res) {



        /* let findPerson :any = await bpm.query({
            query:"select count(principal) as count ,principalJob ,principal from view_fx_from group by principal,principalJob",
            values:[]
        });

        let result :any[] = [];
        for (let i = 0; i < findPerson[0].length; i++) {
            let element = findPerson[0][i];
            
            let dataList :any = await bpm.query({
                query:"select * from view_fx_from where principalJob = '" + element.principalJob + "' and agreementType = 'A'",
                values:[]
            });

            let calc :number = dataList[0].length / (element.count - 0) ;

            result.push({findNum : dataList[0].length , count : element.count ,principal: element.principal ,principalJob:element.principalJob , calc : calc.toFixed(2)});

        }

        for(let i=0;i<result.length-1;i++){
            for(let j=0;j<result.length-1-i;j++){
                if(result[j].calc<result[j+1].calc){
                    let temp=result[j];
                    result[j]=result[j+1];
                    result[j+1]=temp;
                }
            }
        }



        return result; */

        // let formList :any = await bpm.query({//查看所有负责人
        //     query:"select principal ,principalJob,COUNT(client) as client ,SUM(monthDone) as monthDone, SUM(monthAgreement) as monthAgreement, "
        //          + "SUM(monthSub) as monthSub,SUM(sumDone) as sumDone,SUM(sumAgreement) as sumAgreement, SUM(sumSub) as sumSub " 
        //          + "  from view_fx_from where principal = '蔡永' GROUP BY principal, principalJob order by sumSub asc",
        //     values:[]
        // });




    }

    async createDepartment () {
        let result = await dTalkApiUtils.createUser();
        return result ;
    }

    async test1 (i :number = 2 ) {
        let  result = 0;
        switch (i) {
        case 2:{
            result = result + i * 2;
        }
        case 3:
        {
            result = result + i * 3;
        }
        }
        return result;
    }
}

let testService = new TestService();
testService.test1();
export default testService;

